package com.oocl.euc.core.builder;

import com.oocl.euc.common.constant.StatusType;
import com.oocl.euc.core.maintenance.model.Status;
import com.oocl.euc.core.maintenance.repository.StatusRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class StatusBuilder {

    private Status status;
    @Autowired
    private StatusRepository statusRepository;

    public StatusBuilder defaultTaskStatusBuilder() {
        this.status = new Status();
        this.status.setStatusType(StatusType.STATUS_TYPE_TASK);
        this.status.setStatusName("TEST");
        this.status.setActive(true);
        return this;
    }

    public StatusBuilder defaultOverallStatusBuilder() {
        this.status = new Status();
        this.status.setStatusType(StatusType.STATUS_TYPE_OVERALL);
        this.status.setStatusName("TEST2");
        this.status.setActive(true);
        return this;
    }

    public StatusBuilder withRoleName(String statusName) {
        status.setStatusName(statusName);
        return this;
    }

    public StatusBuilder withRoleDesc(String statusDesc) {
        status.setStatusDesc(statusDesc);
        return this;
    }

    public StatusBuilder withStatusActive(Boolean statusActive) {
        status.setActive(statusActive);
        return this;
    }

    public Status create() {
        return status;
    }

    public Status saveToDB() {
        statusRepository.save(status);
        return status;
    }

}
